package com.github.postsanf.yinian.activity;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.github.postsanf.yinian.BaseActivity;
import com.github.postsanf.yinian.R;
import com.github.postsanf.yinian.adapter.LookHistoryAdapter;
import com.github.postsanf.yinian.adapter.TimeCardpicAdapter;
import com.github.postsanf.yinian.bean.YNStatus;
import com.github.postsanf.yinian.constants.ACTIONs;
import com.github.postsanf.yinian.constants.CommonConstants;
import com.github.postsanf.yinian.utils.UIHelper;
import com.github.postsanf.yinian.constants.YNSingleton;
import com.github.postsanf.yinian.entity.YNCommonResponse;
import com.github.postsanf.yinian.entity.YNLoginResponse;
import com.github.postsanf.yinian.utils.ReqUtils;
import com.github.postsanf.yinian.utils.StringUtils;
import com.github.postsanf.yinian.utils.YNInviteSecret;
import com.github.postsanf.yinian.utils.YNUrlHelper;
import com.github.postsanf.yinian.view.LoopViewPager;
import com.github.postsanf.yinian.view.StyleDialog;
import com.litesuits.http.exception.HttpException;
import com.litesuits.http.listener.HttpListener;
import com.litesuits.http.request.StringRequest;
import com.litesuits.http.request.param.HttpMethods;
import com.litesuits.http.response.Response;
import com.umeng.analytics.MobclickAgent;

import org.json.JSONObject;

import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

public class TimeCardDetailActivity extends BaseActivity implements View.OnClickListener {
    public static final String[] mouthlist = new String[]{"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
    protected static final int MSG_UPDATE_IMAGE = 1;
    protected static final int MSG_KEEP_SILENT = 2;
    protected static final int MSG_BREAK_SILENT = 3;
    protected static final int MSG_PAGE_CHANGED = 4;
    protected static final long MSG_DELAY = 6000;
    private YNStatus mCurStatus;
    private List<String> tempUris = new ArrayList<>();
    private boolean noshow = false;
    private TextView timecarde_date_year;
    private TextView timecarde_date_mouth;
    private TextView timecarde_date_ri;
    private LinearLayout timecard_detail_mic;
    private TextView timecard_detail_mic_tx;
    private ImageView lineplay;
    private TextView timecard_detail_from;
    private AnimationDrawable anima;
    private MediaPlayer mediaPlayer;
    boolean isComplete = false;
    //    private MyAdGallery myAdGallery;
    private LinearLayout ll_edit;
    private RelativeLayout rl_look;
    private RecyclerView look_recycler_horizontal;
    private ImageView timecard_detail_comment;
    //    private List<KenBurnsView> listImgs = new ArrayList<KenBurnsView>();
    private LoopViewPager adViewPager;
    private TimeCardpicAdapter timeCardpicAdapter;
    private ImageView tcarde_more;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_time_card_detail);
        registerBroadcastReceiver();
        initDatas();
        initView();
    }

    //注册广播
    private void registerBroadcastReceiver() {
        IntentFilter myIntentFilter = new IntentFilter();
        myIntentFilter.addAction(ACTIONs.actionCloseAlbum);
        this.registerReceiver(mBroadcastReceiver, myIntentFilter);
    }

    // 广播接收
    private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            switch (action) {
                case ACTIONs.actionCloseAlbum:
                    finish();
                    break;
            }
        }
    };

    private void initDatas() {
        mCurStatus = YNSingleton.getInstance().getCurStatus();
        mediaPlayer = new MediaPlayer();
    }


    private void getUserAvatar(int userid) {
        LinkedHashMap<String, String> mParam = new LinkedHashMap<>();
        mParam.put(CommonConstants.YNS_USER_ID, String.valueOf(userid));
        StringRequest req = new StringRequest(getString(R.string.BASE_URL) + getString(R.string.ynShowUserHead))
                .setMethod(HttpMethods.Post)
                .setParamMap(mParam)
                .setHttpListener(new HttpListener<String>(true, false, true) {
                    @Override
                    public void onSuccess(String s, Response<String> response) {
                        YNLoginResponse resUser = gson.fromJson(s, YNLoginResponse.class);
                        if (resUser != null && ReqUtils.isSuccess(resUser.getCode()) && resUser.getData().size() > 0) {
                            String avatarPic = resUser.getData().get(0).getUpic();
                            if (getIntent() != null) {
                                String timeCard = getIntent().getStringExtra("TimeCard");
                                if (TextUtils.equals(timeCard, "TimeCard")) {
                                    timecard_detail_comment.setVisibility(View.GONE);
                                }
                                String lookStatus = getIntent().getStringExtra("lookLimeCard");
                                if (TextUtils.equals(lookStatus, "lookLimeCard")) {
                                    ll_edit.setVisibility(View.GONE);
                                    rl_look.setVisibility(View.VISIBLE);
                                    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(TimeCardDetailActivity.this);
                                    linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
                                    look_recycler_horizontal.setLayoutManager(linearLayoutManager);
                                    LookHistoryAdapter lookHistoryAdapter = new LookHistoryAdapter(TimeCardDetailActivity.this, mCurStatus, String.valueOf(application.getCurID()), avatarPic);
                                    look_recycler_horizontal.setAdapter(lookHistoryAdapter);
                                } else {
                                    ll_edit.setVisibility(View.VISIBLE);
                                    rl_look.setVisibility(View.GONE);
                                }
                            }
                        }
                    }

                    @Override
                    public void onFailure(HttpException e, Response<String> response) {
                        showToast(CommonConstants.YN_NET_LINK);
                    }
                });
        liteHttp.executeAsync(req);
    }

    private void initView() {
        ll_edit = ((LinearLayout) findViewById(R.id.ll_edit));
        rl_look = ((RelativeLayout) findViewById(R.id.rl_look));
        look_recycler_horizontal = ((RecyclerView) findViewById(R.id.look_recycler_horizontal));
        tcarde_more = ((ImageView) findViewById(R.id.tcarde_more));
        tcarde_more.setOnClickListener(this);
        findViewById(R.id.timecard_detail_top_back).setOnClickListener(this);
        findViewById(R.id.timecard_detail_share).setOnClickListener(this);
        timecard_detail_comment = ((ImageView) findViewById(R.id.timecard_detail_comment));
        timecard_detail_comment.setOnClickListener(this);
//        myAdGallery = (MyAdGallery) findViewById(R.id.id_viewpager);
        adViewPager = (LoopViewPager) findViewById(R.id.id_loopviewpager);
        timecarde_date_year = (TextView) findViewById(R.id.timecarde_date_year);
        timecarde_date_mouth = (TextView) findViewById(R.id.timecarde_date_mouth);
        timecarde_date_ri = (TextView) findViewById(R.id.timecarde_date_ri);
        timecard_detail_mic = (LinearLayout) findViewById(R.id.timecard_detail_mic);
        timecard_detail_mic_tx = (TextView) findViewById(R.id.timecard_detail_mic_tx);
        lineplay = (ImageView) findViewById(R.id.timecard_detail_audio_play);
        timecard_detail_from = (TextView) findViewById(R.id.timecard_detail_from);
        String str = null;
        if (StringUtils.isEmpty(mCurStatus.getEmemorytime())) {
            str = mCurStatus.getEuploadtime().split(" ")[0];
        } else {
            str = mCurStatus.getEmemorytime().split(" ")[0];
        }
        timecarde_date_year.setText(str.split("-")[0]);
        timecarde_date_mouth.setText(mouthlist[Integer.parseInt(str.split("-")[1]) - 1]);
        timecarde_date_ri.setText("·" + str.split("-")[2] + "·");
        if (mCurStatus.getEplace() != null && mCurStatus.getEplace().length() > 0) {
            timecard_detail_from.setText(mCurStatus.getEplace());
        }
        timecard_detail_from.setOnClickListener(this);
        if ((mCurStatus.getPublishUser() != null && mCurStatus.getPublishUser().getUserid() == application.getCurID()) ||
                String.valueOf(application.getCurID()).equals(getString(R.string.numberofme))) {
            noshow = true;
        }
        getUserAvatar(application.getCurID());
//        myAdGallery.start(TimeCardDetailActivity.this, tempUris, 5000);
//        myAdGallery.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//            @Override
//            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
//                startActivity(new Intent(TimeCardDetailActivity.this, TimeCardBigPicActivity.class));
//            }
//        });
        if (StringUtils.isEmpty(mCurStatus.getEaudio())) {
            timecard_detail_mic_tx.setText("0'00");
            lineplay.setImageResource(R.drawable.timecard_sound_no);
        } else {
            lineplay.setImageResource(R.drawable.audio_animation_asc_green);
            anima = (AnimationDrawable) lineplay
                    .getDrawable();
            anima.setOneShot(false);
            anima.stop();
            anima.selectDrawable(2);
            timecard_detail_mic.setOnClickListener(this);
            try {
                mediaPlayer.setDataSource(mCurStatus.getEaudio());
                mediaPlayer.prepare();
                mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                                                      @Override
                                                      public void onPrepared(MediaPlayer mp) {
                                                          mictime = mp.getDuration() / 1000;
                                                          timecard_detail_mic_tx.setText(mictime + "''");
                                                          isComplete = true;
                                                      }
                                                  }
                );
                mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                                                        @Override
                                                        public void onCompletion(MediaPlayer mp) {
                                                            anima.stop();
                                                            anima.selectDrawable(2);
                                                        }
                                                    }
                );
            } catch (IOException e) {
                e.printStackTrace();
                timecard_detail_mic_tx.setText("0'00");
                lineplay.setImageResource(R.drawable.timecard_sound_no);
            }
        }
        initUrl();
    }

    private int mictime;

    private void initUrl() {
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < mCurStatus.getUrl().size(); i++) {
            String url = mCurStatus.getUrl().get(i).substring(0, mCurStatus.getUrl().get(i).indexOf("?") + 1);
            String helpurl = YNUrlHelper.getTimeCardUrl(url, 360);
            stringBuilder.append(helpurl).append(",");
        }
        String posturl = stringBuilder.toString().substring(0, stringBuilder.toString().lastIndexOf(","));
        initposturl(posturl);
    }


    private void initposturl(String posturl) {
        LinkedHashMap<String, String> mParam = new LinkedHashMap<>();
        mParam.put("url", posturl);
        StringRequest req = new StringRequest(getString(R.string.BASE_URL) + "GetDownloadToken")
                .setMethod(HttpMethods.Post)
                .setParamMap(mParam)
                .setHttpListener(new HttpListener<String>(true, false, true) {
                    @Override
                    public void onSuccess(String s, Response<String> response) {
                        try {
                            JSONObject jsonObject = new JSONObject(s.toString());
                            if (ReqUtils.isSuccess(jsonObject.optString("code"))) {
                                String[] data = jsonObject.optJSONArray("data").optJSONObject(0).optString("url").split(",");
                                for (int i = 0; i < data.length; i++) {
                                    tempUris.add(data[i]);
                                }
                                timeCardpicAdapter = new TimeCardpicAdapter(TimeCardDetailActivity.this, tempUris);
                                adViewPager.setAdapter(timeCardpicAdapter);
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }

                    @Override
                    public void onFailure(HttpException e, Response<String> response) {
                        showToast(CommonConstants.YN_NET_LINK);
                    }
                });
        liteHttp.executeAsync(req);
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        unregisterReceiver(mBroadcastReceiver);
        mediaPlayer.pause();
//        myAdGallery.stopTimer();
        Glide.get(this).clearMemory();
        System.gc();
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        mediaPlayer.pause();
        mediaPlayer.stop();
        finish();
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.timecard_detail_top_back:
                mediaPlayer.pause();
                mediaPlayer.stop();
                finish();
                break;
            case R.id.timecard_detail_from:
                Intent locaintent = new Intent(TimeCardDetailActivity.this, ShowLocationDialog.class);
                if (mCurStatus.getEplace() != null && mCurStatus.getEplace().length() > 0) {
                    locaintent.putExtra("text", mCurStatus.getEplace());
                } else {
                    locaintent.putExtra("text", "  忆年");
                }
                startActivity(locaintent);
                break;
            case R.id.timecard_detail_mic:
                if (!isComplete)
                    return;
                if (mediaPlayer == null)
                    return;
                if (mediaPlayer.isPlaying()) {
                    mediaPlayer.pause();
                    anima.stop();
                } else {
                    mediaPlayer.start();
                    anima.start();
                }
                break;
//            case R.id.timecard_detail_share:
//                StyleDialog styleDialog = new StyleDialog(TimeCardDetailActivity.this);
//                styleDialog.setCanceledOnTouchOutside(true);
//                styleDialog.show();
//                styleDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
//                    @Override
//                    public void onDismiss(DialogInterface dialog) {
//                        SharedPreferences sp = TimeCardDetailActivity.this.getSharedPreferences("isApart", Context.MODE_PRIVATE);
//                        int isApart = sp.getInt("isApart", 0);
//                        if (isApart == 1) {
//                            Intent intent = new Intent(TimeCardDetailActivity.this, SharePhotoActivity.class);
//                            intent.putStringArrayListExtra(ACTIONs.aAddData, (ArrayList<String>) mCurStatus.getUrl());
//                            TimeCardDetailActivity.this.startActivity(intent);
//                            SharedPreferences.Editor edit = sp.edit();
//                            edit.putInt("isApart", 0);
//                            edit.commit();
//                        } else if (isApart == 2) {
//                            String url = getResources().getString(R.string.SHARE_CARD);
//                            String sec = null;
//                            try {
//                                sec = YNInviteSecret.encryptDES("eventid=" + mCurStatus.getEid(), getResources().getString(R.string.UNKNOW_ID));
//                            } catch (Exception e) {
//                                e.printStackTrace();
//                            }
//                            url = url + sec;
//                            if (getIntent() != null && TextUtils.equals(getIntent().getStringExtra("me"), "me")) {
//                                String avatarUri = UserStatusActivity.avatarPic;
//                                String nickname = UserStatusActivity.nickname;
//                                String avatarPaths = YNUrlHelper.getAvatarUrl(TimeCardDetailActivity.this, avatarUri);
//                                Intent intent = new Intent(TimeCardDetailActivity.this, StatusShareActivity.class);
//                                intent.putExtra("type", "item_timecard_share");
//                                intent.putExtra("share", "share");
//                                intent.putExtra("avatarPaths", avatarPaths);
//                                intent.putExtra("fristpic", tempUris.get(0));
//                                intent.putExtra("title", nickname + " 有点想你，并给你寄了一张语音图集！");
//                                intent.putExtra("desc", "这是我分享给你的风景，以及想对你说的话");
//                                intent.putExtra("url", url);
//                                startActivity(intent);
//                            } else {
//                                String avatarPaths = YNUrlHelper.getAvatarUrl(TimeCardDetailActivity.this, mCurStatus.getPublishUser().getUpic());
//                                Intent intent = new Intent(TimeCardDetailActivity.this, StatusShareActivity.class);
//                                intent.putExtra("share", "share");
//                                intent.putExtra("type", "item_timecard_share");
//                                intent.putExtra("avatarPaths", avatarPaths);
//                                intent.putExtra("fristpic", tempUris.get(0));
//                                intent.putExtra("title", mCurStatus.getPublishUser().getUnickname() + " 有点想你，并给你寄了一张语音图集！");
//                                intent.putExtra("desc", "这是我分享给你的风景，以及想对你说的话");
//                                intent.putExtra("url", url);
//                                startActivity(intent);
//                            }
//                            SharedPreferences.Editor edit = sp.edit();
//                            edit.putInt("isApart", 0);
//                            edit.commit();
//                        }
//                    }
//                });
//                break;
            case R.id.timecard_detail_comment:
                YNSingleton.getInstance().setCurStatus(mCurStatus);
                Intent intent = new Intent(TimeCardDetailActivity.this, MemoryCardDetailCommentActivity.class);
                intent.putExtra("timeCard", "timeCard");
                startActivity(intent);
                finish();
                break;
            case R.id.tcarde_more:
                showPP(view);
                break;
            case R.id.pp_edit:
                YNSingleton.getInstance().setCurStatus(mCurStatus);
                Intent meditIntent = new Intent(TimeCardDetailActivity.this, TimeCardEditActivity.class);
                meditIntent.putExtra("edit", "edit");
                meditIntent.putExtra("mictime", mictime);
                startActivity(meditIntent);
                break;
            case R.id.pp_delete:
                new AlertDialog.Builder(this).setMessage("确定要删除语音图集吗？")
                        .setPositiveButton(R.string.yn_app_ok, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                doDeleteStatus();
                            }
                        })
                        .setNegativeButton(R.string.yn_app_cancel, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                            }
                        }).show();
                break;
            case R.id.timecard_detail_share:
            case R.id.pp_share:
                StyleDialog styleDialog = new StyleDialog(TimeCardDetailActivity.this);
                styleDialog.setCanceledOnTouchOutside(true);
                styleDialog.show();
                styleDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                    @Override
                    public void onDismiss(DialogInterface dialog) {
                        SharedPreferences sp = getSharedPreferences("isApart", Context.MODE_PRIVATE);
                        int isApart = sp.getInt("isApart", 0);
                        if (isApart == 1) {
                            Intent intent = new Intent(TimeCardDetailActivity.this, SharePhotoActivity.class);
                            intent.putStringArrayListExtra(ACTIONs.aAddData, (ArrayList<String>) mCurStatus.getUrl());
                            intent.putExtra("type", "item_timecard_share");
                            startActivity(intent);
                            SharedPreferences.Editor edit = sp.edit();
                            edit.putInt("isApart", 0);
                            edit.commit();
                        } else if (isApart == 2) {
                            String url = getResources().getString(R.string.SHARE_CARD);
                            String sec = null;
                            try {
                                sec = YNInviteSecret.encryptDES("eventid=" + mCurStatus.getEid(), getResources().getString(R.string.UNKNOW_ID));
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            url = url + sec;
                            Intent intent = new Intent(TimeCardDetailActivity.this, StatusShareActivity.class);
                            intent.putExtra("share", "share");
                            intent.putExtra("type", "item_timecard_share");
                            intent.putExtra("avatarPaths", YNUrlHelper.getAvatarUrl(TimeCardDetailActivity.this, mCurStatus.getPublishUser().getUpic()));
                            intent.putExtra("fristpic", mCurStatus.getThumbnail().get(0));
                            intent.putExtra("title", mCurStatus.getPublishUser().getUnickname() + " 有点想你，并给你寄了一张语音图集！");
                            intent.putExtra("desc", "这是我分享给你的风景，以及想对你说的话");
                            intent.putExtra("url", url);
                            startActivity(intent);
                            SharedPreferences.Editor edit = sp.edit();
                            edit.putInt("isApart", 0);
                            edit.commit();
                        } else if (isApart == 3) {
                            String url = getResources().getString(R.string.SHARE_CARD);
                            String sec = null;
                            try {
                                sec = YNInviteSecret.encryptDES("eventid=" + mCurStatus.getEid(), getResources().getString(R.string.UNKNOW_ID));
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            url = url + sec;
                            Intent intent = new Intent(TimeCardDetailActivity.this, PicWallShareActivity.class);
                            intent.putExtra("QRcode", "QRcode");
                            intent.putExtra("UrlShare", url);
                            intent.putExtra("firstPic", mCurStatus.getThumbnail().get(0));
                            intent.putExtra("nickName", mCurStatus.getPublishUser().getUnickname() + "和你分享了一套ta制作的语音图集");
                            intent.putExtra("QRtext", "长按识别二维码查看全部照片");
                            intent.putExtra("above", "语音图集：可以录制自己声音的动态放映的照片集");
                            startActivity(intent);
                            SharedPreferences.Editor edit = sp.edit();
                            edit.putInt("isApart", 0);
                            edit.commit();
                        }
                    }
                });
                break;
        }
    }


    private PopupWindow window;

    protected void showPP(View parent) {
        View v = LayoutInflater.from(TimeCardDetailActivity.this).inflate(R.layout.mcard_detail_pp,
                null);
        View pp_line1 = v.findViewById(R.id.pp_line1);
        View pp_line2 = v.findViewById(R.id.pp_line2);
        TextView edit = (TextView) v.findViewById(R.id.pp_edit);
        edit.setOnClickListener(this);
        TextView delete = (TextView) v.findViewById(R.id.pp_delete);
        delete.setOnClickListener(this);
        v.findViewById(R.id.pp_share).setOnClickListener(this);
        boolean userStatus = getIntent().getBooleanExtra("userStatus",false);
        if (mCurStatus.getPublishUser() != null && mCurStatus.getPublishUser().getUserid() == application.getCurID()||userStatus) {
            window = new PopupWindow(v, UIHelper.dip2px(TimeCardDetailActivity.this, 80), UIHelper.dip2px(TimeCardDetailActivity.this, 120));
        } else {
            window = new PopupWindow(v, UIHelper.dip2px(TimeCardDetailActivity.this, 80), UIHelper.dip2px(TimeCardDetailActivity.this, 40));
            edit.setVisibility(View.GONE);
            delete.setVisibility(View.GONE);
            pp_line1.setVisibility(View.GONE);
            pp_line2.setVisibility(View.GONE);
        }
        window.setAnimationStyle(R.style.pp_AnimationPreview);
        window.setTouchable(true);
        window.setFocusable(true);
        window.setOutsideTouchable(true);
        window.setBackgroundDrawable(new BitmapDrawable());
        window.showAsDropDown(parent);
    }


    // 删除该条动态
    private void doDeleteStatus() {
        LinkedHashMap<String, String> mParam = new LinkedHashMap<>();
        mParam.put(CommonConstants.YNS_EVENT_ID, String.valueOf(mCurStatus.getEid()));
        StringRequest req = new StringRequest(getString(R.string.BASE_URL) + getString(R.string.ynDeleteEvent))
                .setMethod(HttpMethods.Post)
                .setParamMap(mParam)
                .setHttpListener(new HttpListener<String>(true, false, true) {
                    @Override
                    public void onSuccess(String s, Response<String> response) {
                        YNCommonResponse resDelete = gson.fromJson(s, YNCommonResponse.class);
                        if (ReqUtils.isSuccess(resDelete.getCode())) {
                            Intent mIntent = new Intent(ACTIONs.actionStatus);
                            // 同步删除动态
                            mIntent.putExtra(ACTIONs.IsAdd, false);
                            mIntent.putExtra(ACTIONs.StatusId, mCurStatus.getEid());
                            sendBroadcast(mIntent);
                            sendBroadcast(new Intent(ACTIONs.actionGridWallUpdate));
                            finish();
                            if (getIntent().getBooleanExtra("detail", false)) {
                                sendBroadcast(new Intent(ACTIONs.McardDetailFinish));
                            }
                        } else {
                            showToast("删除失败");
                        }
                    }

                    @Override
                    public void onFailure(HttpException e, Response<String> response) {
                        showToast(CommonConstants.YN_NET_LINK);
                    }
                });
        liteHttp.executeAsync(req);
    }

    @Override
    protected void onPause() {
        super.onPause();
        MobclickAgent.onPageEnd(this.getClass().getSimpleName());
        MobclickAgent.onPause(this);
    }


    public void onResume() {
        super.onResume();
        MobclickAgent.onPageStart(this.getClass().getSimpleName());
        MobclickAgent.onResume(this);
    }
}
